projects
/
emacs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
955e370
)
* lisp/emacs-lisp/cl-extra.el (cl-isqrt): Speed up bignum case
author
Stefan Monnier
<monnier@iro.umontreal.ca>
Tue, 25 Jun 2019 21:08:01 +0000
(17:08 -0400)
committer
Stefan Monnier
<monnier@iro.umontreal.ca>
Tue, 25 Jun 2019 21:08:01 +0000
(17:08 -0400)
lisp/emacs-lisp/cl-extra.el
patch
|
blob
|
history
diff --git
a/lisp/emacs-lisp/cl-extra.el
b/lisp/emacs-lisp/cl-extra.el
index 90533295b68f7ffe33d6badb4430630103ca0f51..ca33c56a9580f1d9ad8ba65a5fda4a6d688d5e3e 100644
(file)
--- a/
lisp/emacs-lisp/cl-extra.el
+++ b/
lisp/emacs-lisp/cl-extra.el
@@
-332,10
+332,9
@@
If so, return the true (non-nil) value returned by PREDICATE.
;;;###autoload
(defun cl-isqrt (x)
- "Return the integer square root of the argument."
+ "Return the integer square root of the
(integer)
argument."
(if (and (integerp x) (> x 0))
- (let ((g (cond ((<= x 100) 10) ((<= x 10000) 100)
- ((<= x 1000000) 1000) (t x)))
+ (let ((g (ash 2 (/ (logb x) 2)))
g2)
(while (< (setq g2 (/ (+ g (/ x g)) 2)) g)
(setq g g2))